import { IFeidaoAiBrowserComponent } from '@feidao/web/interfaces';
import nodejs from '@feidao/web/atom/nodejs/msg-b/nodejs';

export default async function a001(fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	console.log('新增修改部门　调用事件');
	fd.data.curr_dept = args[0][0];
	const res = await nodejs(fd.data.spaceid, "dept_find", { filter: { deptid: fd.data.curr_dept.deptid }, page_size: 1 });
	fd.data.curr_dept.parent_dept_code = res[0].parent_dept_code;
	fd.data.curr_dept.parent_dept_name = res[0].parent_dept_name;
	fd.data.curr_dept.deptname = res[0].deptname;
	fd.data.curr_dept._id = res[0]._id;
	if (fd.data.curr_dept.flag == 3) {//修改
		fd.data.node.querySelector<HTMLInputElement>('[data-feidao-id="deptname"]').value = fd.data.curr_dept.deptname;
	} else {//新增同级//新增下级
		fd.data.node.querySelector<HTMLInputElement>('[data-feidao-id="deptname"]').value = '';
	}
	fd.data.node.classList.remove('display-n');
}
